package com.daikin.ktmustwrite

import android.os.Bundle
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import com.daikin.ktmustwrite.app.base.BaseActivity
import com.daikin.ktmustwrite.databinding.ActivityMainBinding
import com.daikin.ktmustwrite.viewmodel.state.MainViewModel
import com.tencent.bugly.beta.Beta
import me.hgj.jetpackmvvm.network.manager.NetState

class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
    private val TAG = "MainActivity"

    override fun layoutId(): Int {
        return R.layout.activity_main
    }

    override fun initView(savedInstanceState: Bundle?) {
//        Beta.checkUpgrade(false, true)

        onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {

            }
        })
    }

    override fun createObserver() {
    }

    override fun onNetworkStateChanged(netState: NetState) {
        super.onNetworkStateChanged(netState)
        if (netState.isSuccess) {
            Toast.makeText(applicationContext, "有网了啊!", Toast.LENGTH_SHORT).show()
        } else {
            Toast.makeText(applicationContext, "断网了呀~~~~", Toast.LENGTH_SHORT).show()
        }
    }
}